import requests
import asyncio
import aiohttp
import time

urls = [
    "http://127.0.0.1:5000/bobo",
    "http://127.0.0.1:5000/jay",
    "http://127.0.0.1:5000/tom"
]
start = time.time()
async def request(url):
    # print("downloading...")
    # #requests模块是同步的，在异步编程过程中不能出现同步模块
    # # repense = requests.get(url)
    # print(repense.text)
    # print("finished")
    async with aiohttp.ClientSession() as session:
       async with await session.get(url) as response:
           page_text = await response.text()
           print(page_text)
task_list = []
for url in urls:
    work = request(url)
    task = asyncio.ensure_future(work)
    task_list.append(task)


loop = asyncio.get_event_loop()
loop.run_until_complete(asyncio.wait(task_list))
print(time.time() - start)